package com.ps.controller;

import org.jboss.logging.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.client.ServiceInstance;
import org.springframework.cloud.client.discovery.DiscoveryClient;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @description: hello controller
 * @author: 谭倾云
 * @create: 2019/08/09
 */
@RestController
@RequestMapping("/helloController")
public class HelloController {
    private final Logger logger = Logger.getLogger(getClass());

    @Autowired
    private DiscoveryClient discoveryClient;

    @RequestMapping(value = "/getName",method = RequestMethod.GET)
    public String exchange(String name, HttpServletResponse response) throws Exception {
        System.out.println("我是你爸爸,你别不信 然而这是事实。");
        System.out.println("哈皮,你就是一个哈皮");
        ServiceInstance instance = discoveryClient.getLocalServiceInstance();
        System.out.println("host:"+instance.getHost()+"  id:"+instance.getServiceId()+"  name:"+name);
        response.setCharacterEncoding("UTF-8");
        return "你要死啊"+name+"?";
    }
}
